import { Injectable, Inject } from '@angular/core';
import { Observable, of, Subject } from 'rxjs';
import { catchError, filter, map } from 'rxjs/operators';

@Injectable()
export class AddVMSService {
    selectGraphics: any;
    selectTemplate: any;
    selectVMSLibrary: any;
    // 筛选框下拉列表
    selectionList = {
        messageCategory: []
    };
    _ss = new Subject<any>();
    cdkDropListConnectId = [];
    showPage = 0;
    // displayMessage = [
    //     {
    //         imgs: [],
    //         templateName: '',
    //         MessageCategory: ''
    //     }
    // ];
    displayMessage: any;
    imgs = [];
    constructor() {}
    setGraphics(data) {
        this.selectGraphics = data;
    }
    setSelectionList(key, value) {
        this.selectionList[key] = value;
    }
    setVMSLibrary(data) {
        this.selectVMSLibrary = data;
    }
    setTemplate(data) {
        this.selectTemplate = data;
    }
    setDisplayMessage(data) {
        this.displayMessage = data;
        this._ss.next(this.displayMessage);
    }
    getDisplayMessage() {
        return this._ss.asObservable();
    }
    updateTemplatePages(index, data) {
        this.displayMessage.templatePages[index] = data;
    }
    clearDisplayMessage() {
        // this.displayMessage = {
        //     category: {
        //         categoryId: null,
        //         categoryName: null
        //     },
        //     msgDisplayId: null,
        //     msgId: null,
        //     templateId: null,
        //     templatePages: [
        //         {
        //             graphicSeq: null, // 播放顺序
        //             pageSeq: null,
        //             graphics: [],
        //             text: {
        //                 text: null,
        //                 textimageUrl: null
        //             }
        //         }
        //     ]
        // };
        this.showPage = 0;
    }
    addTemplatePages(data) {
        this.displayMessage.templatePages.push(data);
    }
    setShowPage(data) {
        this.showPage = data;
    }
}
